home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / addRecentFile.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.8 KB  |  95 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  March 17th, 1998
  22. //  Author:         GG
  23. //
  24. //  Description:
  25. //      addRecentFile, used currently used by Project Viewer.
  26. //        adds filenames to the recent file list.
  27. //
  28.  
  29.  
  30.  
  31. global proc addRecentFile ( string $theFile, string $theType )
  32. {
  33.     string $RecentFilesList[];
  34.     int $i;
  35.     int $nNum;
  36.     int $maxNum;
  37.  
  38.     $maxNum = `optionVar -q "RecentFilesMaxSize"`;
  39.  
  40.     if (!`optionVar -exists "RecentFilesList"`)
  41.     {
  42.         if ( $maxNum > 0 ) {
  43.             optionVar -sva "RecentFilesList" $theFile;
  44.             optionVar -sva "RecentFilesTypeList" $theType;
  45.         }
  46.         if (catch(melCallbackAddRecentFile($theFile)))
  47.             warning("Error in melCallbackAddRecentFile()");
  48.         return;
  49.     }
  50.  
  51.     // get the list
  52.     $RecentFilesList = `optionVar -q "RecentFilesList"`;
  53.     $nNum = size($RecentFilesList);
  54.  
  55.     if ($nNum > 0 )
  56.     {
  57.         if ( !`optionVar -exists "RecentFilesTypeList"`)
  58.         {
  59.             initRecentFilesTypeList( $RecentFilesList );
  60.         }
  61.  
  62.         // search for name in the list.
  63.         for ($i = 0; $i < $nNum; $i++)
  64.         {
  65.             if ($RecentFilesList[$i] == $theFile)
  66.             {
  67.                 // move it to the top.
  68.                 optionVar -rfa "RecentFilesList" $i;
  69.                 optionVar -rfa "RecentFilesTypeList" $i;
  70.                 optionVar -sva "RecentFilesList" $theFile;
  71.                 optionVar -sva "RecentFilesTypeList" $theType;
  72.                 if (catch(melCallbackAddRecentFile($theFile)))
  73.                     warning("Error in melCallbackAddRecentFile()");
  74.                 return;
  75.             }
  76.         }
  77.     }
  78.  
  79.     // not found, append at the end.
  80.     optionVar -sva "RecentFilesList" $theFile;
  81.     optionVar -sva "RecentFilesTypeList" $theType;
  82.     $nNum = `optionVar -arraySize "RecentFilesList"`;
  83.     if ( $nNum > $maxNum )  // default maximum size
  84.     {
  85.         for ( $i = 0; $i < $nNum - $maxNum; $i++ )
  86.         {
  87.             // remove the oldest one.
  88.             optionVar -rfa "RecentFilesList" 0;
  89.             optionVar -rfa "RecentFilesTypeList" 0;
  90.         }
  91.     }
  92.     if (catch(melCallbackAddRecentFile($theFile)))
  93.         warning("Error in melCallbackAddRecentFile()");
  94. }
  95.